import axios from 'axios'
const methods = {
    getCashNote () {
        this.$store.commit('showLoading');
        axios.get('/index/getCash/getCashNote', {
            params: {
                page: this.page,
                dataNum: this.pageSize,
                keyName: '',
                keyWord: ''
            }
        }).then((datas) => {
            var data = datas.data;
            if (data.status === 0) {
                this.allNote = data.data.allNote;
                this.dataTotal = data.data.dataTotal;
            }
            this.$store.commit('hiddenLoading');
        }, (err) => {
            this.$store.commit('hiddenLoading');
            console.log(err)
        })
    },

    //监听路由
    listenRoute () {
        var route = this.$route;
        var query = route.query;
        var page = query.page;
        var keyName = query.keyName;
        var keyWord = query.keyWord;

        this.page = page;
        this.keyName = keyName;
        this.keyWord = keyWord;

        this.getCashNote();

    },
    //行为
    searchData (param) {
        var keyName = param.searchKind;
        var keyWord = param.searchKeyWord;

        var route = this.$route;
        var query = route.query;
        var routePath = route.name;
        query.keyName = keyName;
        query.keyWord = keyWord;
        query.page = this.page;
        this.$router.push({
            path: routePath,
            query: query
        });
        this.listenRoute();
    },
    refresh() {
        this.listenRoute();
    },
    changePage (page) {
        var route = this.$route;
        var query = route.query;
        query.page = page;

        var routePath = route.name;
        this.$router.push({
            path: routePath,
            query: query
        })
        this.listenRoute();

    }
}

export default methods